#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->statusBar->showMessage("未连接到服务器..");

    QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";

    QRegExp ipRegex ("^" + ipRange
                     + "\\." + ipRange
                     + "\\." + ipRange
                     + "\\." + ipRange + "$");

    QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this);
    ui->lineEdit->setValidator(ipValidator);

    client.setLabel(ui->label);
    client.setStatusBar(ui->statusBar);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_load_clicked()
{
     client.start(ui->lineEdit->text(), ui->lineEdit_2->text().toInt());
     ui->statusBar->showMessage("正在连接...");
}

void MainWindow::on_pushButton_send_clicked()
{
    client.startTransfer();
    ui->statusBar->showMessage("正在获取图片...");
}
